package com.bawei.lookfor2204a.view.activity.login

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.lookfor2204a.model.HttpUtils
import com.bawei.lookfor2204a.model.LoginBean
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * 作者：赵亮
 * 时间：2024/10/17 11:22
 * 功能：登录的View Model
 */
class LoginViewModel: ViewModel() {

    // 登录
    val loginSuccess = MutableLiveData<LoginBean>()
    fun login(userName:String, pwd:String) {
        val map = mapOf("userName" to userName, "passwd" to pwd)
        HttpUtils.HttpUtils.apiService.login(map)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe {
                loginSuccess.postValue(it)
            }

    }
}